package com.example.mine_platform.controller;

import com.example.mine_platform.commom.Result;
import com.example.mine_platform.mapper.CheckClockMapper;
import com.example.mine_platform.pojo.entities.CheckClock;
import com.example.mine_platform.pojo.entities.User;
import com.example.mine_platform.service.CheckClockService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
@CrossOrigin(origins = "*")
public class CheckTimeController {
    @Resource
    CheckClockService checkClockService;
    @GetMapping("/search")
    Result getUser(@RequestParam(value="userId", required=true)Integer userId,
                   @RequestParam(value="pageSize", defaultValue="5")Integer pageSize,
                   @RequestParam(value="pageNum",  defaultValue="1")Integer pageNum){
        PageInfo<CheckClock> infos=checkClockService.findBySearch(userId,pageSize,pageNum);
        return  Result.success(infos);
    }
    @PostMapping("/sign")
    Result saveCheckClock(@RequestBody CheckClock checkClock){
        checkClockService.add(checkClock);
        return Result.success();
    }
}
